<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Kinetis Bootloader: Peripheral Interfaces</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="nxp_logo_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Kinetis Bootloader
   &#160;<span id="projectnumber">2.0.0</span>
   </div>
   <div id="projectbrief">Common bootloader for Kinetis devices</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Introduction</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('peripheral_interfaces_page.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Peripheral Interfaces </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1>Overview</h1>
<p>The block diagram below shows the connections between components in the architecture of the peripheral interface.</p>
<div class="image">
<img src="../../doc/image/peripheral_interfaces_block_diagram.png"  alt="peripheral interfaces block diagram"/>
</div>
<p>The CAN interface (not shown) work in a similar fashion.</p>
<p>In this diagram, the byte and packet interfaces are shown to inherit from the control interface.</p>
<p>All peripheral drivers implement an abstract interface built on top of the driver's internal interface. The outermost abstract interface is a packet-level interface. It returns the payload of packets to the caller. Drivers which use framing packets have another abstract interface layer that operates at the byte level. The abstract interfaces allow the higher layers to use exactly the same code regardless which peripheral is being used.</p>
<p>The abstract packet interface feeds into the command and data packet processor. This component interprets the packets returned by the lower layer as command or data packets.</p>
<h1>Abstract control interface</h1>
<p>This control interface provides a common method to initialize and shutdown peripheral drivers. It also provides the means to perform the active peripheral detection. No data transfer functionality is provided by this interface. That is handled by the interfaces that inherit the control interface.</p>
<p>The main reason this interface is separated out from the byte and packet interfaces is to show that it is common between the two. It also allows the driver to provide a single control interface struct definition that can be easily shared.</p>
<div class="fragment"><div class="line"><span class="keyword">struct </span><a class="code" href="group__peripheral.html#struct_peripheral_descriptor">PeripheralDescriptor</a> {</div><div class="line">    uint32_t <a class="code" href="group__peripheral.html#aebff96e4421ee84530b46588d1fecc06">typeMask</a>;</div><div class="line">    uint32_t <a class="code" href="group__peripheral.html#a9ed36c4f5392e9f1819ec7c9eb9aff80">instance</a>;</div><div class="line">    void (*<a class="code" href="group__peripheral.html#a93b4acdd53176451155aadc527ad940f">pinmuxConfig</a>)(uint32_t <a class="code" href="group__peripheral.html#a9ed36c4f5392e9f1819ec7c9eb9aff80">instance</a>, <a class="code" href="group__peripheral.html#gaa37d9314ea323173c2e6a8852ed971db">pinmux_type_t</a> pinmux);</div><div class="line">    <span class="keyword">const</span> <a class="code" href="group__peripheral.html#structperipheral__control__interface__t">peripheral_control_interface_t</a> * <a class="code" href="group__peripheral.html#a06427f58a1a1304383cb326b476083ec">controlInterface</a>;</div><div class="line">    <span class="keyword">const</span> <a class="code" href="group__peripheral.html#structperipheral__byte__inteface__t">peripheral_byte_inteface_t</a> * <a class="code" href="group__peripheral.html#a79163bbbd9e86ab8351ee29f989c7899">byteInterface</a>;</div><div class="line">    <span class="keyword">const</span> <a class="code" href="group__peripheral.html#structperipheral__packet__interface__t">peripheral_packet_interface_t</a> * <a class="code" href="group__peripheral.html#a26772fc6678c309201c894a6e903e4b5">packetInterface</a>;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>_peripheral_control_interface</div><div class="line">{</div><div class="line">    bool (*pollForActivity)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*init)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>, serial_byte_receive_func_t <span class="keyword">function</span>);</div><div class="line">    void (*shutdown)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    void (*pump)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">} <a class="code" href="group__peripheral.html#structperipheral__control__interface__t">peripheral_control_interface_t</a>;</div></div><!-- fragment --><table class="doxtable">
<tr>
<th>Interface </th><th>Description  </th></tr>
<tr>
<td><code>pollForActivity()</code> </td><td>Check whether communications has started. </td></tr>
<tr>
<td><code>init()</code> </td><td>Fully initialize the driver. </td></tr>
<tr>
<td><code>shutdown()</code> </td><td>Shutdown the fully initialized driver. </td></tr>
<tr>
<td><code>pump()</code> </td><td>Give the peripheral interface some processing time. </td></tr>
</table>
<h1>Abstract byte interface</h1>
<p>This interface exists to give the framing packetizer a common interface to talk to for the periperals that use framing packets.</p>
<p>The abstract byte interface inherits the abstract control interface.</p>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>_peripheral_byte_inteface</div><div class="line">{</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*init)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*read)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>, uint8_t * buffer, uint32_t requestedBytes);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*write)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>, <span class="keyword">const</span> uint8_t * buffer, uint32_t byteCount);</div><div class="line">} <a class="code" href="group__peripheral.html#structperipheral__byte__inteface__t">peripheral_byte_inteface_t</a>;</div></div><!-- fragment --><table class="doxtable">
<tr>
<th>Interface </th><th>Description  </th></tr>
<tr>
<td><code>init()</code> </td><td>Initialize the interface. </td></tr>
<tr>
<td><code>read()</code> </td><td>Return the requested number of bytes. Blocks until all bytes available. </td></tr>
<tr>
<td><code>write()</code> </td><td>Write the requested number of bytes. </td></tr>
</table>
<h1>Abstract packet interface</h1>
<p>The abstract packet interface inherits the abstract control interface.</p>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>_peripheral_packet_interface</div><div class="line">{</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*init)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*readPacket)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>, uint8_t ** packet, uint32_t * packetLength, <a class="code" href="group__peripheral.html#ga864fc0d1fbad74e37628f58051c8e3f7">packet_type_t</a> packetType);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*writePacket)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>, <span class="keyword">const</span> uint8_t * packet, uint32_t byteCount, <a class="code" href="group__peripheral.html#ga864fc0d1fbad74e37628f58051c8e3f7">packet_type_t</a> packetType);</div><div class="line">    void (*abortDataPhase)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    <a class="code" href="group__ksdk__common.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> (*finalize)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    uint32_t (*getMaxPacketSize)(<span class="keyword">const</span> peripheral_descriptor_t * <span class="keyword">self</span>);</div><div class="line">    void (*byteReceivedCallback)(uint8_t byte);</div><div class="line">} <a class="code" href="group__peripheral.html#structperipheral__packet__interface__t">peripheral_packet_interface_t</a>;</div></div><!-- fragment --><table class="doxtable">
<tr>
<th>Interface </th><th>Description  </th></tr>
<tr>
<td><code>init()</code> </td><td>Initialize the peripheral. </td></tr>
<tr>
<td><code>readPacket()</code> </td><td>Read a full packet from the peripheral. </td></tr>
<tr>
<td><code>writePacket()</code> </td><td>Send a complete packet out the peripheral. </td></tr>
<tr>
<td><code>abortDataPhase()</code> </td><td>Abort receiving of data packets. </td></tr>
<tr>
<td><code>finalize()</code> </td><td>Shut down the peripheral when done with use. </td></tr>
<tr>
<td><code>getMaxPacketSize()</code> </td><td>Returns the maximum buffer size. </td></tr>
<tr>
<td><code>byteReceivedCallback()</code> </td><td>A byte was received on the interface. </td></tr>
</table>
<h2>Framing packetizer</h2>
<p>The <a class="el" href="group__packet.html">framing packetizer</a> processes framing packets received via the byte interface with which it talks. It builds and validates a framing packet as it reads bytes. And it constructs outgoing framing packets as needed to add flow control information and command or data packets. The framing packet also supports data phase abort.</p>
<h2>USB HID packetizer</h2>
<p>The <a class="el" href="group__usb__hid__peripheral.html">USB HID packetizer</a> implements the abstract packet interface for USB HID, taking advantage of USB's inherent flow control and error detection capabilities. The USB HID packetizer provides a link layer that supports variable length packets and data phase abort.</p>
<h1>Command/data processor</h1>
<p>This component reads complete packets from the abstract packet interface and interprets them as either command packets or data packets. The actual handling of each command is done by command handlers that are called by the command processor. The command handler will tell the command processor whether a data phase is expected and how much data is expected to be received.</p>
<p>If the command/data processor receives a unexpected command or data packet, it will ignore it. In this case, the communications link will resynchronize upon reception of the next valid command. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Mar 7 2016 16:48:23 for Kinetis Bootloader by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
